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ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKCQkkaW5wdXQgPSAkSFRUUF9SQVdfUE9TVF9EQVRBOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKCX0gZWxzZSBpZiAoc3RybGVuKCRIVFRQX1BPU1RfVkFSU1siaW5wdXQiXSk+MCkgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKCQkkaW5wdXQgPSBzdHJpcHNsYXNoZXMoJEhUVFBfUE9TVF9WQVJTWyJpbnB1dCJdKTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCgl9IGVsc2UgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKCQkkaW5wdXQgPSBpbXBsb2RlKCJcclxuIiwgZmlsZSgncGhwOi8vaW5wdXQnKSk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAoJfQoKCSRzZXJ2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tZV0udGFibGVzW3RhYmxlXS5zZWxlY3RlZCA9IGNvbHVtbjsKICAgICAgICAgICAgZGF0YWJhc2VzW2RibmFtZV0uZ2V0b2JqZWN0ICh0YWJsZSk7CiAgICAgICAgfQogICAgICAgIG15LnNldG9iamVjdCAoIGNvbHVtbiApOwogICAgfQogICAgZWxzZSBpZiAocGF0dGVybj0vZGJvXC4oXHcrKVwuKFx3KykvLmV4ZWMoa2V5KSkKICAgIHsKICAgICAgICB2YXIgZGJuYW1lICAgPSBwYXR0ZXJuWzFdOwogICAgICAgIHZhciB0YWJsZSAgICA9IHBhdHRlcm5bMl07IAogICAgICAgIGlmIChzdGF0ZSAmJiBkYXRhYmFzZXNbZGJuYW1lXS50YWJsZXNbdGFibGVdKQogICAgICAgICAgICBkYXRhYmFzZXNbZGJuYW1lXS5nZXRvYmplY3QgKHRhYmxlKTsgCiAgICB9CiAgICBlbHNlIGlmIChwYXR0ZXJuPS9kYm9cLihcdyspLy5leGVjKGtleSkpCiAgICB7IAogICAgICAgIHZhciBkYm5hbWUgICA9IHBhdHRlcm5bMV07IAogICAgICAgIG15LnRhYmxlICAgICA9IG51bGw7CiAgICAgICAgaWYgKHN0YXRlICYmIGRhdGFiYXNlc1tkYm5hbWVdKQogICAgICAgIHsgIAogICAgICAgICAgICBDb250cm9sbGVyLmRhdGFiYXNlbmFtZSA9IGRibmFtZTsKICAgICAgICAgICAgZGF0YWJhc2VzW2RibmFtZV0uZ2V0b2JqZWN0cygpOwogICAgICAgIH0gIAogICAgfQogICAgVmlld3MudHJlZWJhci5pbnZva2UoKTsgCn0KCi8qCiogVklFV1MKKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCnZhciBWaWV3cyA9IHsKICAgIGZvb3RiYXIgOiBWaWV3LmNyZWF0ZSAoJ2Zvb3RiYXInLCAnZGZvb3RlcicsIGZ1bmN0aW9uICgpCiAgICB7IAogICAgICAgIHZhciBjb2wsIG5hbWUsIGxhc3QsIGNvdW50LCBzb3VyY2U9Jy93ZWJzZXJ2aWNlcy9zcGVjaWFsL2NsZWFuJywgaHRtPVtdOyAKICAgICAgICB2YXIgcXVlcnkgPSBDb250cm9sbGVyLnF1ZXJ5Y29sbGVjdGlvbi5zZWxlY3RlZDsKICAgICAgICBpZiAocXVlcnkpCiAgICAgICAgewogICAgICAgICAgICB2YXIgZG9tICAgICAgID0gcXVlcnkucmVzdWx0OwogICAgICAgICAgICB2YXIgbmFtZSAgICAgID0gcXVlcnlbJ25hbWUnXTsKICAgICAgICAgICAgdmFyIGVsYXBzZWQgICA9IG51bGw7CiAgICAgICAgICAgIGlmICghZG9tKSByZXR1cm4gJ1F1ZXJ5IGNvbnRhaW5zIG5vIHJlY29yZHMnOwogICAgICAgICAgICB2YXIgcmVjb3Jkc2V0ID0gZG9tLmdldEVsZW1lbnRzQnlUYWdOYW1lICgncmVjb3Jkc2V0Jyk7CiAgICAgICAgICAgIGZvciAodmFyIHg9MDt4PCByZWNvcmRzZXQubGVuZ3RoO3grKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY291bnQgICAgID0gcGFyc2VJbnQgKHJlY29yZHNldFt4XS5nZXRBdHRyaWJ1dGUgKCdjb3VudCcpKTsKICAgICAgICAgICAgICAgIGVsYXBzZWQgICAgPSByZWNvcmRzZXRbeF0uZ2V0QXR0cmlidXRlICgnZWxhcHNlZCcpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHZhciBoZWlnaHQgPSBDb250cm9sbGVyLmhhc2JpdCggQ29udHJvbGxlci5iaXRzLkZPT1RWSUVXICkgPyA2NCA6IDI0OwogICAgICAgIGZvb3RlciA9IHsgCiAgICAgICAgICAgIG1heGkgOiBmdW5jdGlvbiAocGljLCB0aXRsZSwgY2FwdGlvbikKICAgICAgICAgICAgeyAKICAgICAgICAgICAgICAgIGh0bS5wdXNoICgnPHRkPicgKyBpbWFnZWNyZWF0ZShzb3VyY2UrJy94JyArIGhlaWdodCArICcvJytwaWMpICsgJzwvdGQ+Jyk7CiAgICAgICAgICAgICAgICBodG0ucHVzaCAoJzx0ZD4nKTsKICAgICAgICAgICAgICAgIGh0bS5wdXNoICgnPGZvbnQgc2l6ZT0zIGNvbG9yPSIjMDAwMDY2Ij4nICsgdGl0bGUgKyAnPC9mb250PicpOwogICAgICAgICAgICAgICAgaHRtLnB1c2ggKCc8ZGl2IGNsYXNzPXNtYWxsPicrY2FwdGlvbisnPGJyPjwvZGl2PicpOwogICAgICAgICAgICAgICAgaHRtLnB1c2ggKCc8L3RkPicpOyAKICAgICAgICAgICAgICAgIGh0bS5wdXNoICgnPHRkIHZhbGlnbj0iYm90dG9tIiBub3dyYXA+Jm5ic3A7Jm5ic3A7Jm5ic3A7Jyk7ICAKICAgICAgICAgICAgICAgIGh0bS5wdXNoICgnPC90ZD4nKTsgIAogICAgICAgICAgICB9LAogICAgICAgICAgICBtaW5pIDogZnVuY3Rpb24gKHBpYywgdGl0bGUsIGNhcHRpb24pCiAgICAgICAgICAgIHsgCiAgICAgICAgICAgICAgICBodG0ucHVzaCAoJzx0ZD4nICsgaW1hZ2VjcmVhdGUoc291cmNlKycveCcgKyBoZWlnaHQgKyAnLycrcGljKSArICc8L3RkPicpOwogICAgICAgICAgICAgICAgaHRtLnB1c2ggKCc8dGQgY2xhc3M9c21hbGw+Jyk7CiAgICAgICAgICAgICAgICBodG0ucHVzaCAoJycrY2FwdGlvbisnIDxiPiInICsgdGl0bGUgKyAnIjwvYj4nKTsKICAgICAgICAgICAgICAgIGh0bS5wdXNoICgnPC90ZD4nKTsgIAogICAgICAgICAgICB9IAogICAgICAgIH0KICAgICAgICAKICAgICAgICB2YXIgcmVuZGVyID0gQ29udHJvbGxlci5oYXNiaXQoIENvbnRyb2xsZXIuYml0cy5GT09UVklFVyApID8gZm9vdGVyLm1heGkgOiBmb290ZXIubWluaTsKICAgICAgICAKICAgICAgICBodG0ucHVzaCAoJzx0YWJsZSBjZWxscGFkZGluZz0iMiIgY2VsbHNwYWNpbmc9IjAiPicpOwogICAgICAgIGh0bS5wdXNoICgnPHRyPicpOwogICAgICAgIGlmIChxdWVyeSkKICAgICAgICB7IAogICAgICAgICAgICBodG0ucHVzaCAoIHJlbmRlciAoJzE2OHgyMDguanBnLmdpZicscXVlcnkubmFtZSwnTXlTUUwgUXVlcnknKSApOyAKICAgICAgICB9CiAgICAgICAgZWxzZSBpZiAoQ29udHJvbGxlci50YWJsZSkKICAgICAgICB7IAogICAgICAgICAgICBodG0ucHVzaCAoIHJlbmRlciAoJzE2OHgyMDguanBnLmdpZicsQ29udHJvbGxlci50YWJsZS5uYW1lLCdNeVNRTCBUYWJsZScpICk7IAogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChDb250cm9sbGVyLmRhdGFiYXNlbmFtZSAmJiBDb250cm9sbGVyLmRhdGFiYXNlc1tDb250cm9sbGVyLmRhdGFiYXNlbmFtZV0pCiAgICAgICAgewogICAgICAgICAgICBodG0ucHVzaCAoIHJlbmRlciAoJzMxMngxMDA4LmpwZy5naWYnLENvbnRyb2xsZXIuZGF0YWJhc2VuYW1lLCdNeVNRTCBEYXRhYmFzZSBDb25uZWN0aW9uJykgKTsgCiAgICAgICAgfSAKICAgICAgICBlbHNlCiAgICAgICAgeyAKICAgICAgICAgICAgaHRtLnB1c2ggKCc8dGQgdmFsaWduPSJib3R0b20iPicgKyBpbWFnZWNyZWF0ZShMT0dPX1VSTCxudWxsLGhlaWdodCkgKyAnPC90ZD4nKTsgIAogICAgICAgIH0KICAgICAgICAKICAgICAgICBpZiAocXVlcnkgJiYgY291bnQpCiAgICAgICAgewogICAgICAgICAgICB2YXIgbmV4dCxwcmV2LGN1cnNvcixzaXplID0gcGFyc2VJbnQocXVlcnkucGFnZXNpemUpLHN1ZmZpeD17bGVmdDp7eDonJyxmOm51bGx9LHJpZ2h0Ont4OicnLGY6bnVsbH19OyAKICAgICAgICAgICAgdmFyIHJlPWZ1bmN0aW9uKG4sdikgeyByZXR1cm4gJzx0cj48dGQgbm93cmFwIGNsYXNzPSJzbWFsbCI+JytuKwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAnOjwvdGQ+PHRkIGNsYXNzPSJzbWFsbCIgd2lkdGg9IjEwMCUiJysKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJyBhbGlnbj0icmlnaHQiPicrdisnPC90ZD48L3RyPic7IH07CiAgICAgICAgICAgIG5leHQ9cGFyc2VJbnQocXVlcnkucG9zaXRpb24pK3BhcnNlSW50KHNpemUpO2lmKG5leHQ+Y291bnQpbmV4dD1jb3VudDsKICAgICAgICAgICAgcHJldj1xdWVyeS5wb3NpdGlvbi1zaXplOwogICAgICAgICAgICBjdXJzb3IgICAgICAgICAgICA9IENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuU0NBTEFST1VUUFVUICkgPyBxdWVyeS5zZWxlY3RlZCA6IHF1ZXJ5LnBvc2l0aW9uOwogICAgICAgICAgICBzdWZmaXgucmlnaHQueCAgICA9IG5leHQ9PWNvdW50Pycub2ZmJzonJwogICAgICAgICAgICBzdWZmaXgubGVmdC54ICAgICA9IHByZXY8MD8nLm9mZic6JycKICAgICAgICAgICAgc3VmZml4LnJpZ2h0LmYgICAgPSBuZXh0PT1jb3VudD9pbWFnZWNyZWF0ZTppbWFnZWxpbms7CiAgICAgICAgICAgIHN1ZmZpeC5sZWZ0LmYgICAgID0gcHJldjwwP2ltYWdlY3JlYXRlOmltYWdlbGluazsKICAgICAgICAgICAgaHRtLnB1c2ggKCc8dGQgbm93cmFwIHZhbGlnbj0idG9wIj4nKTsKICAgICAgICAgICAgaHRtLnB1c2ggKCc8dGFibGUgd2lkdGg9IjEwMCI+Jyk7CiAgICAgICAgICAgIGlmIChDb250cm9sbGVyLmhhc2JpdCggQ29udHJvbGxlci5iaXRzLkZPT1RWSUVXICkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGh0bS5wdXNoICggcmUgKCdUb3RhbCByb3dzJywgY291bnQpICk7CiAgICAgICAgICAgICAgICBodG0ucHVzaCAoIHJlICgnU3RhcnRpbmcgYXQnLCBwYXJzZUludChjdXJzb3IpICsgMSkgKTsKICAgICAgICAgICAgICAgIGlmICghQ29udHJvbGxlci5oYXNiaXQoIENvbnRyb2xsZXIuYml0cy5TQ0FMQVJPVVRQVVQgKSkKICAgICAgICAgICAgICAgICAgICBodG0ucHVzaCAoIHJlICgndG8nLCBuZXh0KSApOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGh0bS5wdXNoICgnPC90cj48L3RhYmxlPicpOwogICAgICAgICAgICBodG0ucHVzaCAoJzwvdGQ+Jyk7CiAgICAgICAgICAgIGh0bS5wdXNoICgnPHRkIG5vd3JhcCAnKyhDb250cm9sbGVyLmhhc2JpdCggQ29udHJvbGxlci5iaXRzLkZPT1RWSUVXICk/J3ZhbGlnbj0idG9wIic6JycpKyc+Jyk7CiAgICAgICAgICAgIGh0bS5wdXNoICgnJm5ic3A7Jm5ic3A7Jyk7CiAgICAgICAgICAgIGlmIChjb3VudCA+IHNpemUpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGh0bS5wdXNoICgnPHNlbGVjdCBvbmNoYW5nZT1cJ0NvbnRyb2xsZXIucmVvcGVub2JqZWN0KCInICsgcXVlcnkua2V5ICsnIiwgdGhpcy52YWx1ZSlcJz4nKTsKICAgICAgICAgICAgICAgIGZvciAodmFyIHg9MDt4PGNvdW50O3grPXNpemUpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgbGFzdD14K3NpemU7aWYobGFzdD5jb3VudClsYXN0PWNvdW50OwogICAgICAgICAgICAgICAgICAgIGh0bS5wdXNoICgnPG9wdGlvbiAnKyBzZWwgKHF1ZXJ5LnBvc2l0aW9uPT14KSsnIHZhbHVlPSInICsgeCArICciPicgKyAoeCsxKSArICcgdG8gJyArIGxhc3QpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaHRtLnB1c2ggKCc8L3NlbGVjdD4nKTsKICAgICAgICAgICAgICAgIGh0bS5wdXNoICgnIG9mICcpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGh0bS5wdXNoICgnJyArIGNvdW50ICsgJyByZWNvcmRzJyk7CiAgICAgICAgICAgIAogICAgICAgICAgICBpZiAoIUNvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuU0NBTEFST1VUUFVUICkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmIChDb250cm9sbGVyLmhhc2JpdCggQ29udHJvbGxlci5iaXRzLkZPT1RWSUVXICkpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgaHRtLnB1c2ggKCcsIDxicj4mbmJzcDsmbmJzcDs8aW5wdXQgb25jaGFuZ2U9IkNvbnRyb2xsZXIucmVzZXRvYmplY3QodGhpcy52YWx1ZSkiJyk7CiAgICAgICAgICAgICAgICAgICAgaHRtLnB1c2ggKCcgc2l6ZT0iMyIgdmFsdWU9Iicrc2l6ZSsnIi8+IHBlciBwYWdlLicpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHN1ZmZpeC5sZWZ0LmYgID0gZnVuY3Rpb24gKGlnbm9yZSwgY29tbWFuZCkgeyByZXR1cm4gdGV4dGxpbmsgKCcmIzE3MTtiYWNrJywgY29tbWFuZCwgc3VmZml4LmxlZnQueD09Jy5vZmYnPydjb2xvcjpncmF5JzonJyk7IH0KICAgICAgICAgICAgICAgICAgICBzdWZmaXgucmlnaHQuZiA9IGZ1bmN0aW9uIChpZ25vcmUsIGNvbW1hbmQpIHsgcmV0dXJuIHRleHRsaW5rICgnbmV4dCYjMTg3OycsIGNvbW1hbmQsIHN1ZmZpeC5yaWdodC54PT0nLm9mZic/J2NvbG9yOmdyYXknOicnKTsgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IAogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsgCiAgICAgICAgICAgICAgICBzdWZmaXgubGVmdC5mICA9IGZ1bmN0aW9uICh4KSB7IHJldHVybiBpbWFnZWxpbmsoeCwnQ29udHJvbGxlci5xdWVyeWNvbGxlY3Rpb24uc2VsZWN0ZWQuYWR2YW5jZSgtMSknKTsgfSAKICAgICAgICAgICAgICAgIHN1ZmZpeC5yaWdodC5mID0gZnVuY3Rpb24gKHgpIHsgcmV0dXJuIGltYWdlbGluayh4LCdDb250cm9sbGVyLnF1ZXJ5Y29sbGVjdGlvbi5zZWxlY3RlZC5hZHZhbmNlKDEpJyk7IH0gCiAgICAgICAgICAgICAgICBzdWZmaXgucmlnaHQueCA9IGN1cnNvcj5jb3VudC0yPycub2ZmJzonJwogICAgICAgICAgICAgICAgc3VmZml4LmxlZnQueCAgPSBjdXJzb3I8MT8nLm9mZic6JycKICAgICAgICAgICAgfQogICAgICAgICAgICBodG0ucHVzaCAoJyZuYnNwOycpOwogICAgICAgICAgICBodG0ucHVzaCAoJzwvdGQ+Jyk7CiAgICAgICAgICAgIGh0bS5wdXNoICgnPHRkIG5vd3JhcCAnKyhDb250cm9sbGVyLmhhc2JpdCggQ29udHJvbGxlci5iaXRzLkZPT1RWSUVXICk/Jyc6JycpKyc+Jyk7CiAgICAgICAgICAgIC8vaWYgKENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuRk9PVFZJRVcgKSkKICAgICAgICAgICAgLy97IAogICAgICAgICAgICAgICAgaHRtLnB1c2ggKCc8dGFibGU+PHRyPicpOwogICAgICAgICAgICAgICAgaHRtLnB1c2ggKCc8dGQ+JyArIHN1ZmZpeC5sZWZ0LmYgKCcvd2Vic2VydmljZXMvaW1hZ2VzL2ZhbmN5LmxlZnQnK3N1ZmZpeC5sZWZ0LngrJy5wbmcnLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg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gIGh0bS5wdXNoICgnPC90cj48L3RhYmxlPicpOwogICAgICAgIHJldHVybiBodG0uam9pbiAoJycpOwogICAgfSksCiAgICAvKi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4qLwogICAgdG9nZ2xlciA6IFZpZXcuY3JlYXRlICgndG9nZ2xlcicsICdkc3BsaXR0ZXInLCBmdW5jdGlvbiAoKQogICAgeyAKICAgICAgICB2YXIgdHJlZWJpdCA9IENvbnRyb2xsZXIuZ2V0Yml0KCBDb250cm9sbGVyLmJpdHMuVFJFRVZJRVcgKTsgCiAgICAgICAgdmFyIGFjdGl2ZSAgPSBDb250cm9sbGVyLmhhc2JpdCggQ29udHJvbGxlci5iaXRzLlRSRUVWSUVXICk7IAogICAgICAgIHJldHVybiAnPGltZyBzcmM9IicrUElDX1JPT1QrJy93ZWJzZXJ2aWNlcy9pbWFnZXMvY2xlYXIuZ2lmIiB3aWR0aD04Pic7IAogICAgICAgIHJldHVybiBpbWFnZWxpbmsgKFBJQ19ST09UKycvd2Vic2VydmljZXMvaW1hZ2VzL2Nsb3NlXycgKyAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoYWN0aXZlID8gJ29mZicgOiAnb24nKSArICcuZ2lmJywgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICdDb250cm9sbGVyLnNldHZhbHVlKCJ2aWV3YXMiLCAnK3RyZWViaXQrJyknCiAgICAgICAgICAgICAgICAgICAgICAgICApOyAKICAgIH0sbnVsbCxmdW5jdGlvbiAoKSB7IAogICAgICAgIHZhciBhY3RpdmUgID0gQ29udHJvbGxlci5oYXNiaXQoIENvbnRyb2xsZXIuYml0cy5UUkVFVklFVyApOyAKICAgICAgICB3aW5kb3cucmVzaXplTGlzdGVuZXJzWydkdHJlZSddLm9mZnNldFggPSBhY3RpdmUgPyAoQ29udHJvbGxlci50cmVld2lkdGggKyAncHgnKSA6ICcwcHgnCiAgICAgICAgd2luZG93LnJlc2l6ZUxpc3RlbmVyLmludm9rZSAoKTsgCiAgICB9KSwKICAgIC8qLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLiovCiAgICB2dG9nZ2xlciA6IFZpZXcuY3JlYXRlICgndnRvZ2dsZXInLCAnZHZzcGxpdHRlcicsIGZ1bmN0aW9uICgpCiAgICB7IAogICAgICAgIHZhciBmb290Yml0ID0gQ29udHJvbGxlci5nZXRiaXQoIENvbnRyb2xsZXIuYml0cy5GT09UVklFVyApOyAKICAgICAgICB2YXIgYWN0aXZlICA9IENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuRk9PVFZJRVcgKTsgCiAgICAgICAgcmV0dXJuIGltYWdlbGluayAoUElDX1JPT1QrJy93ZWJzZXJ2aWNlcy9pbWFnZXMvY2xvc2VfJyArIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIChhY3RpdmUgPyAnZG93bicgOiAndXAnKSArICcuZ2lmJywgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICdDb250cm9sbGVyLnNldHZhbHVlKCJ2aWV3YXMiLCAnK2Zvb3RiaXQrJyknCiAgICAgICAgICAgICAgICAgICAgICAgICApOyAKICAgIH0sbnVsbCxmdW5jdGlvbiAoKSAgIAogICAgeyAgICAKICAgICAgICB2YXIgYWN0aXZlICA9IENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuRk9PVFZJRVcgKTsgCiAgICAgICAgd2luZG93LnJlc2l6ZUxpc3RlbmVyc1snZGJvZHknXS5vZmZzZXRZID0gYWN0aXZlID8gMTAwIDogNDA7CiAgICAgICAgd2luZG93LnJlc2l6ZUxpc3RlbmVyc1snZHRyZWUnXS5vZmZzZXRZID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0ZXh0JywgZHJhdyA6IGR9LAogICAgICAgICAgICAgICAgIHtrZXk6ICdwYXNzd29yZCcsIG5hbWUgOiAnUGFzc3dvcmQnLCB0eXBlIDogJ3Bhc3N3b3JkJywgZHJhdyA6IGR9ICAKICAgICAgICAgICAgXTsKICAgICAgICAgICAgZm9yICh2YXIgeCBpbiBvKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBodG0ucHVzaCAob1t4XS5kcmF3IChkYXRhYmFzZVtvW3hdLmtleV0pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBodG0ucHVzaCAoJzx0cj48dGQgY29sc3Bhbj0yIGFsaWduPXJpZ2h0PicgKTsKICAgICAgICAgICAgaHRtLnB1c2ggKCc8aW5wdXQgb25jbGljaz0iQ29udHJvbGxlci5kYXRhYmFzZXNbQ29udHJvbGxlci5kYXRhYmFzZW5hbWVdLnNhdmUoKSInICk7CiAgICAgICAgICAgIGh0bS5wdXNoICgnIHR5cGU9YnV0dG9uIHZhbHVlPSJTYXZlIFNldHRpbmdzIj4nICk7CiAgICAgICAgICAgIGh0bS5wdXNoICgnPGlucHV0IG9uY2xpY2s9IkNvbnRyb2xsZXIuZGF0YWJhc2VzW0NvbnRyb2xsZXIuZGF0YWJhc2VuYW1lXS5kZXN0cnVjdCgpIicgKTsKICAgICAgICAgICAgaHRtLnB1c2ggKCcgdHlwZT1idXR0b24gdmFsdWU9IkRlbGV0ZSBDb25uZWN0aW9uIj4nICk7CiAgICAgICAgICAgIGh0bS5wdXNoICgnPC90ZD48L3RyPicgKTsKICAgICAgICAgICAgaHRtLnB1c2ggKCc8L3RhYmxlPicpOwogICAgICAgICAgICBodG0ucHVzaCAoJzwvYmxvY2txdW90ZT4nKTsKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgaWYgKGRhdGFiYXNlLlNIT1dFWFBPUlQpCiAgICAgICAgewogICAgICAgICAgICBodG0ucHVzaCAoJzxibG9ja3F1b3RlPjxoMz5FeHBvcnQgJytkYXRhYmFzZS5uYW1lKyc8L2gzPicpOwogICAgICAgICAgICBodG0ucHVzaCAoJzx0YWJsZT4nKTsgCiAgICAgICAgICAgIGh0bS5wdXNoICgnPHRyPicpOyAKICAgICAgICAgICAgaHRtLnB1c2ggKCc8dGQgdmFsaWduPSJ0b3AiPjwvdGQ+Jyk7IAogICAgICAgICAgICBodG0ucHVzaCAoJzx0ZCB2YWxpZ249InRvcCI+Jyk7IAogICAgICAgICAgICBodG0ucHVzaCAoJzx0ZXh0YXJlYSByb3dzPTIwIGNvbHM9NTA+Jyk7IAogICAgICAgICAgICBodG0ucHVzaCAoJycpOyAKCQkJZm9yICh2YXIgeCBpbiBkYXRhYmFzZS50YWJsZXMpIGh0bS5wdXNoIChkYXRhYmFzZS50YWJsZXNbeF0uZG9leHBvcnQoKSk7IAogICAgICAgICAgICBodG0ucHVzaCAoJzwvdGV4dGFyZWE+Jyk7IAogICAgICAgICAgICBodG0ucHVzaCAoJzwvdGQ+Jyk7IAogICAgICAgICAgICBodG0ucHVzaCAoJzwvdHI+Jyk7IAogICAgICAgICAgICBodG0ucHVzaCAoJzwvdGFibGU+Jyk7CiAgICAgICAgICAgIGh0bS5wdXNoICgnPC9ibG9ja3F1b3RlPicpOwogICAgICAgIH0KICAgICAgICAKICAgICAgICB2YXIgcm93PVtdOwogICAgICAgIGZvciAodmFyIHggaW4gZGF0YWJhc2UudGFibGVzKSByb3cucHVzaCAoZGF0YWJhc2UudGFibGVzW3hdLmRyYXcoKSk7IAogICAgICAgIGlmIChyb3cubGVuZ3RoID4gMCkKICAgICAgICB7CiAgICAgICAgICAgIGh0bS5wdXNoICgnPHRhYmxlIGNlbGxzcGFjaW5nPSIwIiBzdHlsZT0iYm9yZGVyOnNvbGlkIDFweDtib3JkZXItY29sb3I6Z3JheSAjZjBmMGYwICNmMGYwZjAgZ3JheSI+Jyk7CiAgICAgICAgICAgIGh0bS5wdXNoICgnPHRyPicpOwogICAgICAgICAgICBodG0ucHVzaCAoJzx0ZCBjb2xzcG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Z2Fpbi48L3NtYWxsPicpOwogICAgICAgIHJldHVybiBodG0uam9pbiAoJycpOwogICAgfSAgICAKICAgIAogICAgaWYgKENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuVEVYVE9VVFBVVCApKQogICAgewogICAgICAgIGh0bS5wdXNoICgnPHhtcD4nKTsKICAgICAgICBodG0ucHVzaCAoJyAjJyArIHJlcGVhdCAoJyAnLCA4KSArICcgJyk7CiAgICB9CiAgICBlbHNlCiAgICB7CiAgICAgICAgaHRtLnB1c2ggKCc8dGFibGUgY2VsbHNwYWNpbmc9MCBjZWxscGFkZGluZz0yIGJnY29sb3I9IiNjMGMwYzAiPicpOwogICAgICAgIGlmICghQ29udHJvbGxlci5oYXNiaXQoIENvbnRyb2xsZXIuYml0cy5TQ0FMQVJPVVRQVVQgKSkKICAgICAgICAgICAgaHRtLnB1c2ggKCc8dHI+PHRkIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNlMGUwZTAiIGNsYXNzPSJoZWFkZXIiPiZuYnNwOzwvdGQ+Jyk7CiAgICB9CiAgICAKICAgIGlmIChyZWNvcmRzLmxlbmd0aCkKICAgIHsgCiAgICAgICAgaWYgKENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuU0NBTEFST1VUUFVUICkpCiAgICAgICAgewogICAgICAgICAgICByZWNvcmQgPSByZWNvcmRzW2N1cnNvcl07IAogICAgICAgICAgICBpZiAoIXJlY29yZCkgcmV0dXJuICdObyBjdXJyZW50IHJlY29yZCAnICsgY3Vyc29yOwogICAgICAgICAgICBjb2w9cmVjb3JkLmNoaWxkTm9kZXM7CiAgICAgICAgICAgIHJlbmRlciA9IGZ1bmN0aW9uICh4LGYsaSkgeyByZXR1cm4gJzx0cj48dGQgc3R5bGU9ImJhY2tncm91bmQtY29sb3I6I2UwZTBlMCIgY2xhc3M9ImhlYWRlciI+JysKICAgICAgICAgICAgICAgIGYrJzwvdGQ+PHRkIGNsYXNzPSJoZWFkZXIiPjxpbnB1dCBzaXplPSI1MCIgdmFsdWU9IicrKHg9PU5VTEw/Jyc6eCkrJyI+PC90ZD48L3RyPic7IH0KICAgICAgICAgICAgZm9yICh2YXIgaT0wO2k8Y29sLmxlbmd0aDtpKyspCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmKGNvbFtpXS5ub2RlTmFtZT09J2ZpZWxkJykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBuYW1lID0gY29sW2ldLmdldEF0dHJpYnV0ZSAoIm5hbWUiKTsKICAgICAgICAgICAgICAgICAgICBzaXplID0gY29sW2ldLmdldEF0dHJpYnV0ZSAoInNpemUiKTsKICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IGNvbFtpXS5maXJzdENoaWxkID8gY29sW2ldLmZpcnN0Q2hpbGQubm9kZVZhbHVlIDogTlVMTDsKICAgICAgICAgICAgICAgICAgICBpZiAoQ29udHJvbGxlci5oYXNiaXQoIENvbnRyb2xsZXIuYml0cy5URVhUT1VUUFVUICkpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBodG0ucHVzaCAocGFkICh2YWx1ZSwgc2l6ZSkgKyAnICcpOwogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgaHRtLnB1c2ggKCByZW5kZXIodmFsdWUsIG5hbWUsIHgpICk7CiAgICAgICAgICAgICAgICAgICAgfSAKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBodG0ucHVzaCAoICc8L3RhYmxlPicgKTsKICAgICAgICAgICAgcmV0dXJuIGh0bS5qb2luICgnJyk7CiAgICAgICAgfQogICAgCiAgICAgICAgdmFyIHUsIHRleHQsIHVuZGVybGluZT1bcmVwZWF0ICgnLScsIDEwKSArICcgJ107CiAgICAgICAgY29sPXJlY29yZHNbMF0uY2hpbGROb2RlczsKICAgICAgICBmb3IgKHZhciBpPTA7aTxjb2wubGVuZ3RoO2krKykKICAgICAgICB7CiAgICAgICAgICAgIGlmKGNvbFtpXS5ub2RlTmFtZT09J2ZpZWxkJykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgbmFtZSA9IGNvbFtpXS5nZXRBdHRyaWJ1dGUgKCJuYW1lIik7CiAgICAgICAgICAgICAgICBzaXplID0gY29sW2ldLmdldEF0dHJpYnV0ZSAoInNpemUiKTsKICAgICAgICAgICAgICAgIGlmIChDb250cm9sbGVyLmhhc2JpdCggQ29udHJvbGxlci5iaXRzLlRFWFRPVVRQVVQgKSkKICAgICAgICAgICAgICAgIHsgCiAgICAgICAgICAgICAgICAgICAgdT1yZXBlYXQgKCctJywgc2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgaHRtLnB1c2ggKHBhZCAobmFtZSsnKCcrc2l6ZSsnKScsIHNpemUpICsgJyAnKTsKICAgICAgICAgICAgICAgICAgICB1bmRlcmxpbmUucHVzaCAocGFkKHUsIHNpemUpICsgJyAnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBodG0ucHVzaCAoJzx0ZCBzdHlsZT0iYmFja2dyb3VuZC1jb2xvcjojZTBlMGUwIiBub3dyYXAgY2xhc3M9ImhlYWRlciI+JyArIG5hbWUgKyAnJm5ic3A7PC90ZD4nKTsKICAgICAgICAgICAgICAgIH0gCiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgCiAgICAgICAgaWYgKENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuVEVYVE9VVFBVVCApKQogICAgICAgIHsKICAgICAgICAgICAgaHRtLnB1c2ggKGxmICsgdW5kZXJsaW5lLmpvaW4gKCcnKSArIGxmKTsgCiAgICAgICAgfQogICAgICAgIGVsc2UKICAgICAgICB7CiAgICAgICAgICAgIGh0bS5wdXNoICgnPC90cj4nKTsKICAgICAgICB9IAogICAgICAgIAogICAgICAgIGZvciAodmFyIHg9MDt4PHJlY29yZHMubGVuZ3RoO3grKykKICAgICAgICB7CiAgICAgICAgICAgIHBvcyAgICA9IHgrMStwYXJzZUludChxdWVyeS5wb3NpdGlvbikKCQkJdGV4dCAgID0gdGV4dGxpbmsocG9zLCdDb250cm9sbGVyLnF1ZXJ5Y29sbGVjdGlvbi5zZWxlY3RlZC5zZWxlY3QoJytwb3MrJyknKTsKICAgICAgICAgICAgcmVuZGVyID0gcG9zPT1xdWVyeS5zZWxlY3RlZCA/IHRvaW5wdXQgOiB0b3ZhbHVlOwogICAgICAgICAgICBpZiAoQ29udHJvbGxlci5oYXNiaXQoIENvbnRyb2xsZXIuYml0cy5URVhUT1VUUFVUICkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGh0bS5wdXNoICgnICcgKyBwYWQgKHBvcy50b1N0cmluZygpLCA5KSArICcgJyk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBodG0ucHVzaCAoJzx0cj48dGQgYWxpZ249cmlnaHQgc3R5bGU9ImJhY2tncm91bmQtY29sb3I6I2UwZTBlMCIgY2xhc3M9IicgKyAKCQkJCSAgIChwb3M9PXF1ZXJ5LnNlbGVjdGVkPycnOidoZWFkZXInKSArICciPicgKyB0ZXh0ICsgJzwvdGQ+Jyk7ICAKICAgICAgICAgICAgfSAKICAgICAgICAgICAgCiAgICAgICAgICAgIGNvbD1yZWNvcmRzW3hdLmNoaWxkTm9kZXM7CiAgICAgICAgICAgIGZvciAodmFyIGk9MDtpPGNvbC5sZW5ndGg7aSsrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZihjb2xbaV0ubm9kZU5hbWU9PSdmaWVsZCcpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgbmFtZSA9IGNvbFtpXS5nZXRBdHRyaWJ1dGUgKCJuYW1lIik7CiAgICAgICAgICAgICAgICAgICAgc2l6ZSA9IGNvbFtpXS5nZXRBdHRyaWJ1dGUgKCJzaXplIik7CiAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBjb2xbaV0uZmlyc3RDaGlsZCA/IGNvbFtpXS5maXJzdENoaWxkLm5vZGVWYWx1ZSA6IE5VTEw7CiAgICAgICAgICAgICAgICAgICAgaWYgKENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuVEVYVE9VVFBVVCApKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgaHRtLnB1c2ggKHBhZCAodmFsdWUsIHNpemUpICsgJyAnKTsKICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIGh0bS5wdXNoICggcmVuZGVyKHZhbHVlLCBuYW1lLCB4KSApOwogICAgICAgICAgICAgICAgICAgIH0gCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuVEVYVE9VVFBVVCApKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBodG0ucHVzaCAobGYpOyAKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGh0bS5wdXNoICgnPC90cj4nKTsKICAgICAgICAgICAgfSAKICAgICAgICB9CiAgICB9IGVsc2UgcmV0dXJuICdRdWVyeSByZXR1cm5lZCBubyByZWNvcmRzJzsKICAgIAogICAgaWYgKENvbnRyb2xsZXIuaGFzYml0KCBDb250cm9sbGVyLmJpdHMuVEVYVE9VVFBVVCApKQogICAgewogICAgICAgIGh0bS5wdXNoICgnPC94bXA+Jyk7CiAgICB9CiAgICBlbHNlCiAgICB7CiAgICAgICA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VzaCAoJzwvZGl2PicpOwogICAgICAgICAgICB2YXIgY29sdW1ucyA9IGRhdGFiYXNlLnRhYmxlc1tDb250cm9sbGVyLnF1ZXJ5dGFibGVdLmNvbHVtbnM7CiAgICAgICAgICAgIGZvciAodmFyIHggaW4gY29sdW1ucykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaHRtLnB1c2ggKCc8aW5wdXQgdHlwZT1jaGVja2JveCAnK2NoayhxdWVyeS5oYXNjb2x1bW4oQ29udHJvbGxlci5xdWVyeXRhYmxlLGNvbHVtbnNbeF0ubmFtZSkpKycgJyk7CiAgICAgICAgICAgICAgICBodG0ucHVzaCAoJyBvbmNsaWNrPVwnQ29udHJvbGxlci5xdWVyeWNvbGxlY3Rpb24uc2VsZWN0ZWQuYWRkY29sdW1uKCInICsgQ29udHJvbGxlci5xdWVyeXRhYmxlICsgJyIsIicgKyBjb2x1bW5zW3hdLm5hbWUgKyAnIilcJycpOwogICAgICAgICAgICAgICAgaHRtLnB1c2ggKCcgPicpOyAKICAgICAgICAgICAgICAgIGh0bS5wdXNoIChjb2x1bW5zW3hdLm5hbWUpOwogICAgICAgICAgICAgICAgaHRtLnB1c2ggKCc8YnI+Jyk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIHsKICAgICAgICAgICAgZm9yICh2YXIgeCBpbiBkYXRhYmFzZS50YWJsZXMpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGh0bS5wdXNoICgnPGlucHV0IHR5cGU9Y2hlY2tib3ggJytjaGsoIHF1ZXJ5LmJ1aWxkZXIudGFibGVzW2RhdGFiYXNlLnRhYmxlc1t4XS5uYW1lXSApKycgJyk7CiAgICAgICAgICAgICAgICBodG0ucHVzaCAoJyBvbmNsaWNrPVwnQ29udHJvbGxlci5xdWVyeWNvbGxlY3Rpb24uc2VsZWN0ZWQuZGVsdGFibGUoIicgKyBkYXRhYmFzZS50YWJsZXNbeF0ubmFtZSArICciKVwnJyk7CiAgICAgICAgICAgICAgICBodG0ucHVzaCAoJyA+Jyk7IAogICAgICAgICAgICAgICAgaHRtLnB1c2ggKHRleHRsaW5rKGRhdGFiYXNlLnRhYmxlc1t4XS5uYW1lLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJ0NvbnRyb2xsZXIucXVlcnljb2xsZWN0aW9uLnNlbGVjdGVkLmFkZCAoIicrZGF0YWJhc2UudGFibGVzW3hdLm5hbWUrJyIpJwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICkgKTsgCiAgICAgICAgICAgICAgICBodG0ucHVzaCAoJzxicj4nKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBodG0ucHVzaCAoJzwvdGQ+PC90cj48L3RhYmxlPjwvZGl2PicpOwogICAgfQogICAgcmV0dXJuIGh0bS5qb2luICgnJyk7Cn0pOwovLwptYWluLmFkZCAoYnVpbGRxdWVyeSwgcXVlcnl0ZXh0LCB3b3Jrc3BhY2UsIHRvb2xiYXIpOwpxdWVyaWVyLmFkZCAoYnVpbGRxdWVyeSwgcXVlcnl0ZXh0LCBxdWVyeXBhbmUsIHRvb2xiYXIpOwpmb3IgKHZhciB4IGluIFZpZXdzKQp7CiAgICBtYWluLmFkZCAoVmlld3NbeF0pOwogICAgcXVlcmllci5hZGQgKFZpZXdzW3hdKTsKfQogCi8qCiogQ09OVFJPTExFUiBFVkVOVFMKKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCkNvbnRyb2xsZXIub25kYXRhYmFzZWxvYWRlZCA9IGZ1bmN0aW9uIChkYXRhKQp7CiAgICB2YXIgbmFtZSwgZG9tPVhtbERvY3VtZW50LmNyZWF0ZSgpOyAgIAogICAgaWYgKGRvbS5sb2FkWE1MIChkYXRhKSkgIAogICAgeyAKICAgICAgICB2YXIgbXksIGtleSx0YWJsZW5hbWUgPSBudWxsOwogICAgICAgIHZhciB0YWJsZXMgPSBkb20uZ2V0RWxlbWVudHNCeVRhZ05hbWUgKCd0YWJsZXMnKTsKICAgICAgICB2YXIgbm9kZW5hbWUgPSAnZGJvLicgKyBDb250cm9sbGVyLmRhdGFiYXNlbmFtZTsKICAgICAgICB0cmVlLml0ZW1zW25vZGVuYW1lXS5jbGVhcigpOwogICAgICAgIGlmICh0YWJsZXMubGVuZ3RoID09IDApIAogICAgICAgIHsKICAgICAgICAgICAgbWFpbi5pbnZva2UgKCk7CiAgICAgICAgICAgIHJldHVybiBjb25maXJtICgnTm8gdGFibGVzIHdoZXJlIGZvdW5kIGluIHRoZSByZXF1ZXN0LicpOwogICAgICAgIH0KICAgICAgICAKICAgICAgICBmb3IgKHZhciB4PTA7eDx0YWJsZXMubGVuZ3RoO3grKykgQ29udHJvbGxlci5kYXRhYmFzZW5hbWU9dGFibGVzW3hdLmdldEF0dHJpYnV0ZSAoJ2RhdGFiYXNlJyk7CiAgICAgICAgICAKICAgICAgICB2YXIgdGFibGUgPSBkb20uZ2V0RWxlbWVudHNCeVRhZ05hbWUgKCd0YWJsZScpOwogICAgICAKICAgICAgICBkb2N1bWVudC50aXRsZSA9IEFQUExJQ0FUSU9OX05BTUUgKyAnIC0gJyArIG5vZGVuYW1lOwogICAgICAgIGZvciAodmFyIHg9MDt4PHRhYmxlLmxlbmd0aDt4KyspCiAgICAgICAgeyAgCiAgICAgICAgICAgIHRhYmxlbmFtZSA9IHRhYmxlW3hdLmdldEF0dHJpYnV0ZSAoJ25hbWUnKQogICAgICAgICAgICBrZXkgID0gbm9kZW5hbWUgKyAnLicgKyB0YWJsZW5hbWUKICAgICAgICAgICAgdHJlZS5hZGQgKHRhYmxlbmFtZSwga2V5LCBub2RlbmFtZSk7CiAgICAgICAgICAgIHRyZWUuaXRlbXNba2V5XS5pY29uPWltYWdlY3JlYXRlICgnL3dlYnNlcnZpY2VzL2ltYWdlcy9pY29fZ3JpZC5qcGcnKTsKICAgICAgICAgICA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ICAgICAKICAgICAgICBhdHRhY2ggPSAnZGJvLicgKyBkYm5hbWUgKyAnLicgKyBuYW1lOyAKICAgICAgICB0cmVlLml0ZW1zW2F0dGFjaF0uY2xlYXIoKTsgCiAgICAgICAgCiAgICAgICAgZG9jdW1lbnQudGl0bGUgPSBBUFBMSUNBVElPTl9OQU1FICsgJyAtICcgKyBhdHRhY2g7CiAgICAgICAgQ29udHJvbGxlci5kYXRhYmFzZW5hbWUgICAgID0gZGJuYW1lOyAgICAgIAogICAgICAgIENvbnRyb2xsZXIudGFibGUgICAgICAgICAgICAgPSBDb250cm9sbGVyLmRhdGFiYXNlc1tkYm5hbWVdLnRhYmxlc1tuYW1lXTsKICAgICAgICBDb250cm9sbGVyLnRhYmxlLmNvbHVtbnMgICAgID0gW107CiAgICAgICAgZm9yICh2YXIgeD0wO3g8Y29sdW1ucy5sZW5ndGg7eCsrKQogICAgICAgIHsgIAogICAgICAgICAgICBuYW1lICAgICAgID0gY29sdW1uc1t4XS5nZXRBdHRyaWJ1dGUgKCduYW1lJyk7IAogICAgICAgICAgICBrZXkgICAgICAgID0gYXR0YWNoICsgJy4nICsgbmFtZTsKICAgICAgICAgICAgY29sdW1uICAgICA9IENvbHVtbi5jcmVhdGUoY29sdW1uc1t4XSwgYXR0YWNoKTsKICAgICAgICAgICAgZGVzYyAgICA9ICc8YiBjbGFzcz1zbWFsbD4nICsgY29sdW1uLnR5cGUgKyAoY29sdW1uLnNpemUmJmNvbHVtbi5zaXplLmxlbmd0aD4wPycgKCcrY29sdW1uLnNpemUrJyknOicnKSArICc8L2I+JzsKICAgICAgICAgICAgdHJlZS5hZGQgKG5hbWUgKyAnICcgKyBkZXNjLCBrZXksIGF0dGFjaCk7CiAgICAgICAgICAgIHRyZWUuaXRlbXNba2V5XS5pY29uPSc8aW1nIHNyYz0iJyArIFBJQ19ST09UICsgJy93ZWJzZXJ2aWNlcy9pbWFnZXMvaS5zLnByb3BlcnR5LmdpZiIgYWxpZ249ImFic21pZGRsZSI+JzsKICAgICAgICAgICAgaWYgKGNvbHVtbi5rZXkgJiYgY29sdW1uLmtleS5sZW5ndGggPiAwKSBDb250cm9sbGVyLnRhYmxlLmtleSA9IG5hbWU7CiAgICAgICAgICAgIENvbnRyb2xsZXIudGFibGUuY29sdW1ucy5wdXNoICggY29sdW1uICk7CiAgICAgICAgfQogICAgICAgIGlmIChjYWxsYmFjayAmJiB0eXBlb2YoY2FsbGJhY2spPT0nZnVuY3Rpb24nKSByZXR1cm4gY2FsbGJhY2soKTsKICAgICAgICBtYWluLmludm9rZSAoKTsKICAgIH0KfQoKQ29udHJvbGxlci5vbm9wZW4gPSBmdW5jdGlvbiAoZGF0YSkKeyAKICAgIHZhciBhdHRhY2gsIG5hbWUsIGRvbT1YbWxEb2N1bWVudC5jcmVhdGUoKTsgICAKICAgIGlmIChkb20ubG9hZFhNTCAoZGF0YSkpICAKICAgIHsgIAogICAgICAgIENvbnRyb2xsZXIucmVjb3Jkc2V0ID0gZG9tOwogICAgICAgIHF1ZXJpZXIuaW52b2tlICgpOwogICAgfQp9CgovKgoqIENPTlRST0xMRVIgTUVUSE9EUwoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KQ29udHJvbGxlci5kZWxldGV0YWJsZSA9IGZ1bmN0aW9uICgpCnsKICAgIGlmIChDb250cm9sbGVyLmRhdGFiYXNlbmFtZSAmJiBDb250cm9sbGVyLmRhdGFiYXNlc1tDb250cm9sbGVyLmRhdGFiYXNlbmFtZV0pCiAgICAgICAgQ29udHJvbGxlci5kYXRhYmFzZXNbQ29udHJvbGxlci5kYXRhYmFzZW5hbWVdLnJlbW92ZSAoQ29udHJvbGxlci50YWJsZS5uYW1lKTsKfQoKQ29udHJvbGxlci5uZXd0YWJsZSA9IGZ1bmN0aW9uICgpCnsKICAgIHZhciB4OwogICAgaWYgKHg9cHJvbXB0KCdFbnRlciBhI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GVWYWx1ZTsKICAgICAgICB9ICAKICAgICAgICBpZiAoY29va2llLnZpZXdhcykgQ29udHJvbGxlci52aWV3YXMgPSBjb29raWUudmlld2FzOwogICAgICAgIGlmIChjb29raWUudHJlZXdpZHRoKSBDb250cm9sbGVyLnRyZWV3aWR0aCA9IGNvb2tpZS50cmVld2lkdGg7CiAgICB9ICAKICAgIGJlZ2luUmVuZGVyICgpIDsKfQovKgoqIENPTlRST0xMRVIgUFJPUEVSVElFUwoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KQ29udHJvbGxlci5xdWVyeWNvbGxlY3Rpb24gPSB7CiAgICBpbmRleCA6IC0xLAogICAgc2VsZWN0ZWQgOiBudWxsLAogICAgc2VsZWN0IDogZnVuY3Rpb24gKHgpIHsgdGhpcy5zZWxlY3RlZD14O21haW4uaW52b2tlKCk7fSwKICAgIGl0ZW1zIDogW10sCiAgICBrZXlzOiB7fQp9CkNvbnRyb2xsZXIuZmlyc3RrZXkgICAgID0gMDsKQ29udHJvbGxlci5sYXN0a2V5ICAgICAgPSAwOwpDb250cm9sbGVyLmtleXBhZ2UgICAgICA9IFtdOwpDb250cm9sbGVyLnRhYmxlICAgICAgICA9IG51bGw7CkNvbnRyb2xsZXIudGFibGVzICAgICAgID0ge307CkNvbnRyb2xsZXIuZGF0YWJhc2VzICAgID0ge307CkNvbnRyb2xsZXIucGFnZXNpemUgICAgID0gMTAwOwpDb250cm9sbGVyLnRyZWV3aWR0aCAgICA9IDIwMDsKCnZhciBiaXRzPVsnVFJFRVZJRVcnLCdDUkVBVEVORVcnLCdGT09UVklFVycsJ1NIT1dPVVRQVVQnLCdURVhUT1VUUFVUJywnQlVJTERRVUVSWScsJ1NDQUxBUk9VVFBVVCcsJ1NIT1dDQVBUSU9OUyddOyAgCkNvbnRyb2xsZXIuYml0cz17fTtmb3IgKHZhciB4PTA7eDxi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AnICsgdGFibGVuYW1lICsgJyBTRVQgJyArCiAgICAgICAgICBuYW1lICsgJz0iJyArIHZhbHVlICsgJyInICsKICAgICAgICAgJyBXSEVSRSAnICsgd2hlcmUuam9pbiAoJyBBTkQgJykgOwogICAgcXVlcnkudXBkYXRlIChzcWwsIGZ1bmN0aW9uIChkYXRhLCBpZCkKICAgIHsKICAgICAgICBxdWVyeS5zZXR2YWx1ZSAobmFtZSwgaW5kZXgsIHZhbHVlKTsgCiAgICAgICAgRXZlbnQucmVsb2FkICgpOwogICAgfSk7IAp9IAoKdmFyIGRyb3BtZW51ID0gZnVuY3Rpb24gKGVsZW1lbnQpCnsKICAgIHZhciBvPXsKICAgICAgICBlbGVtZW50ICA6IGRvY3VtZW50LmdldEVsZW1lbnRCeUlkIChlbGVtZW50KSwgCiAgICAgICAgb24gICAgICAgOiBudWxsLCAKICAgICAgICBib3ggICAgICA6IG51bGwsIAogICAgICAgIGl0ZW1zICAgIDogWwogICAgICAgICAgICB7ZHJhdyA6IGZ1bmN0aW9uKCkge3JldHVybiAnaXRlbSAxJzt9fSwKICAgICAgICAgICAge2RyYXcgOiBmdW5jdGlvbigpIHtyZXR1cm4gJ2l0ZW0gMic7fX0sCiAgICAgICAgICAgIHtkcmF3IDogZnVuY3Rpb24oKSB7cmV0dXJuICdpdGVtIDMnO319LAogICAgICAgICAgICB7ZHJhdyA6IGZ1bmN0aW9uKCkge3JldHVybiAnaXRlbSA0Jzt9fSAgCiAgICAgICAgXSwgCiAgICAgICAgZGlzcGxheSAgOiBmdW5jdGlvbiAoZSkgCiAgICAgICAgewogICAgICAgICAgICB2YXIgaHRtPVtdOwogICAgICAgICAgICBmb3IgKHZhciB4IGluIHRoaXMuaXRlbXMpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGh0bS5wdXNoICh0aGlzLml0ZW1zW3hdLmRyYXcoKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmFyIHBvcyA9Z2V0UG9zaXRpb24odGhpcy5lbGVtZW50KTsKICAgICAgICAgICAgdGhpcy5ib3guaW5uZXJIVE1MID0gaHRtLmpvaW4gKCc8YnI+Jyk7CiAgICAgICAgICAgIHRoaXMuYm94LnN0eWxlLnRvcCA9IChwb3MueSArIHRoaXMuZWxlbWVudC5vZmZzZXRIZWlnaHQpICsgJ3B4JzsKICAgICAgICAgICAgdGhpcy5ib3guc3R5bGUubGVmdCA9IHBvcy54ICsgJ3B4JzsKICAgICAgICAgICAgdGhpcy5ib3guc3R5bGUuZGlzcGxheSA9ICdpbmxpbmUnOwogICAgICAgICAgICB0aGlzLm9uPXRydWU7CiAgICAgICAgICAgIAogICAgICAgIH0gLCAKICAgICAgICB1bmRpc3BsYXkgOiBmdW5jdGlvbiAoZSkKICAgICAgICB7IAogICAgICAgICAgICB0aGlzLmJveC5zdHlsZS5kaXNwbGF5ID0gJ25vbmUnOwogICAgICAgICAgICB0aGlzLm9uPWZhbHNlOwogICAgICAgIH0gLCAKICAgICAgICBpbnZva2UgICA6IGZ1bmN0aW9uIChlKQogICAgICAgIHsgCiAgICAgICAgICAgIGlmIChlLm5hbWU9PSdtb3VzZWRvd24nJiZlLmlkPT10aGlzLmVsZW1lbnQuaWQpIHRoaXMuZGlzcGxheShlKTsgCiAgICAgICAgICAgIGlmIChlLm5hbWU9PSdtb3VzZXVwJyYmdGhpcy5vbikgdGhpcy51bmRpc3BsYXkoZSk7IAogICAgICAgIH0sCiAgICAgICAgbG9hZCA6IGZ1bmN0aW9uICgpCiAgICAgICAgeyAKICAgICAgICAgICAgbWFrZURyYWdnYWJsZSAodGhpcy5lbGVtZW50KTsKICAgICAgICAgICAgd2luZG93Lm1vdXNlRG93bkxpc3RlbmVyLnN1YnNjcmliZSAodGhpcyk7CiAgICAgICAgICAgIHdpbmRvdy5tb3VzZVVwTGlzdGVuZXIuc3Vic2NyaWJlICh0aGlzKTsKICAgICAgICAgICAgd2luZG93Lm1vdXNlTW92ZUxpc3RlbmVyLnN1YnNjcmliZSAodGhpcyk7CiAgICAgICAgICAgIAogICAgICAgICAgICAKICAgICAgICAgICAgdmFyIGRpdml0ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnZGl2Jyk7IAogICAgICAgICAgICBkaXZpdC5pZCA9IHRoaXMuZWxlbWVudC5pZCArICdfX19tZW51JzsKICAgICAgICAgICAgZGl2aXQuc3R5bGUucG9zaXRpb24gPSAnYWJzb2x1dGUnOwogICAgICAgICAgICBkb2N1bWVudC5ib2R5LmFwcGVuZENoaWxkKGRpdml0KTsKCiAgICAgICAgICAgIHRoaXMuYm94PWRvY3VtZW50LmdldEVsZW1lbnRCeUlkIChkaXZpdC5pZCk7CiAgICAKICAgICAgICB9CiAgICB9IAogICAgCiAgICAKICAgIG8ubG9hZCAoKTsKICAgIHJldHVybiBvOwp9CgogICAgCi8qCiogR0xPQkFML0RFRkFVTFQgUFJPUEVSVElFUwoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KdmFyIHJlPS8oXHcrKVwoKFxkKylcKSsvOwp2YXIgY29va2llICAgICAgICA9IHt9OyAKdmFyIFBJQ19ST09UICAgICAgPSAnaHR0cDovL3d3dy4xMDFzdHJhdGZvcmQuY29tJzsKdmFyIExPR09fVVJMICAgICAgPSAnL3dlYnNlcnZpY2VzL2ltYWdlcy95b3Vyc3FsLnBuZyc7CnZhciBEQVRBX1VSTCAgICAgID0gJ2Nvbm5lY3Rvci5waHAnOwp2YXIgQ09ORklHX1VSTCAgICA9ICdhcHBsaWNhdGlvbi54bWwnOyAKdmFyIERBVEFUWVBFICAgICAgPSAiVElOWUlOVCxTTUFMTElOVCxNRURJVU1JTlQsSU5ULElOVEVHRVIsQklHSU5ULFJFQUwsRE9VQkxFLEZMT0FULERFQ0lNQUwsTlVNRVJJQyxEQVRFLCIgKyAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICJUSU1FLFRJ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Jysod2lkdGg/J3dpZHRoPSInK3dpZHRoKyciJzonJykrJyAnKyhoZWlnaHQ/J2hlaWdodD0iJytoZWlnaHQrJyInOicnKSsnIHNyYz0iJyArIFBJQ19ST09UICsgc3JjICsgJyIgYWxpZ249ImFic21pZGRsZSI+JzsgfQoKCmZ1bmN0aW9uIHN0YXJ0ICgpCnsgCgogICAgdmFyIHRtcCA9IERBVEFfVVJMOwogICAgREFUQV9VUkwgPSBDT05GSUdfVVJMOyAKICAgIHNob3dfd2FpdF9tZXNzYWdlICgnbG9hZGluZyBjb25maWd1cmF0aW9uLi4uJyk7CiAgICBXZWJzZXJ2aWNlLmdldGZpbGUgKCdwYXRoJywgJycsIGZ1bmN0aW9uIChkYXRhKSAKICAgIHsgIAogICAgICAgIHZhciBkb209WG1sRG9jdW1lbnQuY3JlYXRlKCk7ICAgCiAgICAgICAgaWYgKGRvbS5sb2FkWE1MIChkYXRhKSkgIAogICAgICAgIHsgICAKICAgICAgICAgICAgdmFyIG5hbWUsIHZhbHVlLCBhZGQgPSBkb20uZ2V0RWxlbWVudHNCeVRhZ05hbWUgKCdkYXRhYmFzZScpOyAgIAogICAgICAgICAgICBDb250cm9sbGVyLmRhdGFiYXNlcz17Y291bnQ6MH07CiAgICAgICAgICAgIENvbnRyb2xsZXIuZGF0YWJhc2VuYW1lPW51bGw7CiAgICAgICAgICAgIGZvciAodmFyIHg9MDt4PGFkZC5sZW5ndGg7eCsrKQogICAgICAgICAgICB7ICAKICAgICAgICAgICAgICAgIG5hbWUgPSBhZGRbeF0uZ2V0QXR0cmlidXRlICgnbmFtZScpOwogICAgICAgICAgICAgICAgQ29udHJvbGxlci5kYXRhYmFzZXNbbmFtZV09RGF0YWJhc2UuY3JlYXRlIChuYW1lLCBhZGRbeF0pOwogICAgICAgICAgICAgICAgQ29udHJvbGxlci5kYXRhYmFzZXMuY291bnQgKys7CiAgICAgICAgICAgIH0gIAogICAgICAgICAgICBzaG93X3dhaXRfbWVzc2FnZSAoJ2dldHR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uYW1lKXJldHVybiB0cnVlO30gcmV0dXJuIGZhbHNlOyB9LAoJCWFkZGNvbHVtbiA6IGZ1bmN0aW9uICh0YWJsZSwgbmFtZSkgeyBpZiAodGhpcy5oYXNjb2x1bW4odGFibGUsbmFtZSkpIHJldHVybiB0aGlzLmRlbGNvbHVtbih0YWJsZSxuYW1lKTsgdGhpcy50YWJsZXNbdGFibGVdLmNvbHVtbnMucHVzaCAobmFtZSk7IH0sCgkJZGVsY29sdW1uIDogZnVuY3Rpb24gKHRhYmxlLCBuYW1lKSB7IHZhciBvPVtdLGE9dGhpcy50YWJsZXNbdGFibGVdLmNvbHVtbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGUgaW4gYSkge2lmIChhW2VdIT1uYW1lKW8ucHVzaChhW2VdKTt9IAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRhYmxlc1t0YWJsZV0uY29sdW1ucz1vOyByZXR1cm4gbzsgfSwKCQlkZWx0YWJsZSAgOiBmdW5jdGlvbiAodGFibGUpIHsgdmFyIG89W10sYT10aGlzLnRhYmxlcztmb3IgKHZhciBlIGluIGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFbZV0ubmFtZSE9dGFibGUpb1tlXT1hW2VdO30gdGhpcy50YWJsZXM9bzsgcmV0dXJuIG87IH0sIAoJCWFkZHRhYmxlICA6IGZ1bmN0aW9uIChuYW1lKSB7IGlmICh0aGlzLnRhYmxlc1tuYW1lXSkgcmV0dXJuIHRydWU7IAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGFibGVzW25hbWVdID0geyBuYW1lOm5hbWUsY29sdW1uczpbXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGRjb2x1bW46ZnVuY3Rpb24oeCkgeyB0aGlzLmNvbHVtbnMucHVzaCh4KTsg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AgICAgdmFyIG89Q29udHJvbGxlci5xdWVyeWNvbGxlY3Rpb24uaXRlbXM7CiAgICAgICAgICAgICAgZm9yICh2YXIgeD0wO3g8by5sZW5ndGg7eCsrKQogICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICBpZiAoaWQ9PW9beF0ucmVxdWVzdCkKICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICB2YXIgZG9tPVhtbERvY3VtZW50LmNyZWF0ZSgpOyAgIAogICAgICAgICAgICAgICAgICAgICBpZiAoZG9tLmxvYWRYTUwgKGRhdGEpKSAgCiAgICAgICAgICAgICAgICAgICAgIHsgIAogICAgICAgICAgICAgICAgICAgICAgICAgb1t4XS5yZXN1bHQgPSBkb207CiAgICAgICAgICAgICAgICAgICAgICAgICBDb250cm9sbGVyLnF1ZXJ5Y29sbGVjdGlvbi5pbmRleCA9IHg7CiAgICAgICAgICAgICAgICAgICAgICAgICBDb250cm9sbGVyLnF1ZXJ5Y29sbGVjdGlvbi5zZWxlY3RlZCA9IG9beF07CiAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyaWVyLmludm9rZSAoKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICB9KTsKICAgICAgIH0KICAgIH0gCgkKCW8ua2V5ID0gZGF0YWJhc2UubmFtZSArICcuJyArIG5hbWU7CglyZXR1cm4gbzsKfQoKCmZ1bmN0aW9uIFRhYmxlICgpIHt9ClRhYmxlLmNyZWF0ZSA9IGZ1bmN0aW9uIChub2RlLCBkYm9iamVjdCkKewoJdmFyIG9iamVjdD0geyAKCQlub2RlIAkJOiBub2RlLCAKCQlsb2FkIAkJOiBmdW5jdGlvbigpIHsgdmFyIG89dGhpcy5ub2RlLmF0dHJpYnV0ZXM7Zm9yICh2YXIgZT0wO2U8by5sZW5ndGg7ZSsrKSB0aGlzW29bZV0ubmFtZV09b1tl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